#include <stdio.h>
#define SIZE 7

int arr[SIZE],n = 0;

int hash_math(int k)
{
	return k % 7;
}

void hash_insert(int k)
{
	if(n == 7)
	{
		printf("the hash array is full\n");
		return;
	}
	int i = hash_math(k);
	while(arr[i] != 0)
	{
		i++;
		if(i == 7)
			i = 0;
	}
	arr[i] = k;
	n++;
}

int hash_search(int x)
{
	int i = hash_math(x);
	int t = i;
	while(arr[i] != x)
	{
		i++;
		if(i == 7)
			i = 0;
		if(i == t)
		{
			return -1;
		}
	}
	return i;
}

int main()
{
	int selection;
	int x;
	while(1)
	{
		printf("1.insert  2.search  0.exit\n");
		printf("Please enter:");
		scanf("%d",&selection);
		switch(selection)
		{
		case 1:
			scanf("%d",&x);
			hash_insert(x);
			break;
		case 2:
			scanf("%d",&x);
			x = hash_search(x);
			printf("%d\n",x);
			break;
		case 0:
			return 0;
		}
	}
	return 0;
}
